USE [BMIG_MENSUAL_POST_CADENA]

 -- creating the store procedure
IF EXISTS (SELECT name 
	   FROM   sysobjects 
	   WHERE  name = 'WASP_M0007_CABECERA_FINAL'
	   AND 	  type = 'P') 
	DROP PROCEDURE [dbo].[WASP_M0007_CABECERA_FINAL]
GO
CREATE PROCEDURE [dbo].[WASP_M0007_CABECERA_FINAL] AS
begin
  begin
    SELECT     NroCuotas, CAST(PrimaBrutaCaja / 1.19 AS decimal(10, 4)) AS PrimaNetaCaja, PrimaBrutaCaja
    into	dbo.cabecera_produccion_cantidad_ant
    FROM         dbo.cabecera_producion_prueba_ant
  end 
  begin
    SELECT     'H' AS TipoRegistro, NULL AS fechaProceso, COUNT(PrimaNetaCaja) AS CantRegVentas, CAST(SUM(PrimaNetaCaja) AS varchar(14)) AS totalPrimaNeta, 
                          CAST(SUM(PrimaBrutaCaja) AS varchar(14)) AS totalPrimaBruta, CAST('' AS char(294)) AS filler
    into 	dbo.cabecera_produccion_cabecera_ant                      
    FROM         dbo.cabecera_produccion_cantidad_ant
   end
END